<?php

namespace Aquarii\HttpClient;

class HttpClient
{
    protected $client;

    public function __construct(array $config = [])
    {
        $this->client = new \GuzzleHttp\Client(array_merge([
            // 设置重定向(allow_redirects)
            \GuzzleHttp\RequestOptions::ALLOW_REDIRECTS => true,
            // 连接超时(connect_timeout)
            \GuzzleHttp\RequestOptions::CONNECT_TIMEOUT => 2.0,
            // 调试开关(debug)
            \GuzzleHttp\RequestOptions::DEBUG => false,
            // 使用流响应，而非下载响应(stream)
            \GuzzleHttp\RequestOptions::STREAM => false,
            // 请求时验证SSL证书行为, 默认使用操作系统提供的CA包
            \GuzzleHttp\RequestOptions::VERIFY => true,
        ], $config));
    }

    public static function send(RequestInterface $request, callable $call = null)
    {
        // $client = new Client();
        // $headers = [
        //   'Content-Type' => 'application/json'
        // ];
        // $body = '112ee';
        // $request = new Request('POST', '12e?aa=bb&cc=122&aa=333', $headers, $body);
        // $res = $client->sendAsync($request)->wait();
        // echo $res->getBody();
    }

    /**
     * Get Request
     */
    public static function get()
    {

    }

    /**
     * Post Request
     */
    public static function post()
    {

    }

    /**
     * Upload File
     */
    public static function upload()
    {

    }
}
